import { MigrationInterface, QueryRunner } from "typeorm";

export class AccountsTableCreated1713733848886 implements MigrationInterface {
    name = "AccountsTableCreated1713733848886";

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(
            `CREATE TABLE "accounts" ("id" SERIAL NOT NULL, "roles" jsonb NOT NULL DEFAULT '["student"]', "userName" character varying NOT NULL, "passwordHash" character varying NOT NULL, "firstName" character varying, "lastName" character varying, "email" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, "needChangePassword" boolean NOT NULL DEFAULT false, "isBlocked" boolean NOT NULL DEFAULT false, CONSTRAINT "accounts__email__uk" UNIQUE ("email"), CONSTRAINT "accounts__userName__uk" UNIQUE ("userName"), CONSTRAINT "accounts__id__pk" PRIMARY KEY ("id"))`
        );
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`DROP TABLE "accounts"`);
    }
}
